package com.alice.springcloud.controller;

import com.alibaba.fastjson.JSON;
import com.alice.springcloud.pojo.Dept;
import com.alice.springcloud.service.DeptClientService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
public class DeptConsumerController {

    private final DeptClientService deptClientService;

    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept){
        return this.deptClientService.addDept(dept);
    }

    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id){
        return this.deptClientService.queryById(id);
    }

    @RequestMapping("/consumer/dept/list")
    public Object getList(){
        return JSON.toJSON(this.deptClientService.queryAll());
    }

}
